import math;
from pylab import *;

class Wave:
  TIME = [];
  wav_isOsc = 0;
  wav_amp = 0;
  wav_frq = 0;
  wav_vals = [];
  wav_tim_up = 0;
  wav_tim_down = 0;

  def __init__(self,a,f,t,dt):
    self.TIME = range(0,int(float(t)/dt));
    self.wav_isOsc = 1;
    self.wav_amp = a;
    self.wav_frq = f;
    #self.wav_vals = [(float(self.wav_amp)/2)*math.sin(((k)*dt*self.wav_frq)*2*math.pi) +float(self.wav_amp)/2     for k in self.TIME];
    self.wav_vals = [(float(self.wav_amp)/2)*math.sin(((k)*dt*self.wav_frq)*2*math.pi) +float(self.wav_amp)/2     for k in self.TIME];
    self.wav_tim_up = (1.0/self.wav_frq)/2.0;
    self.wav_tim_down = (1.0/self.wav_frq)/2.0; 


  def __str__(self):
    return "Oscillating: "+str(self.wav_isOsc)+", Amp: "+str(self.amp)+", Frq: "+str(self.frq);

  def get_vals(self):
    return self.wav_vals;

  def get_time(self):
    return self.TIME;

  def get_amp(self):
    return self.wav_amp;
  
  def get_frq(self):
    return self.wav_frq;

  def get_per(self):
    return 1.0/self.wav_frq;

  def get_tim_up(self):
    return self.wav_tim_up;

  def get_tim_down(self):
    return self.wav_tim_down;
  
  def dbg_plot(self):
    plot(self.TIME, self.vals, linewidth=1.0)
    xlabel('time')
    ylabel('vals')
    title(str(self))
    grid(True)
    show()  
